<template>
  <div class="mv">
    <div class="fanhui">
      <span class="iconfont icon-fanhui" @click="back()"></span>
    </div>
    <video :src="mvurl" controls autoplay muted></video>
    <div class="content" v-if="mvlist != null">
      <div class="left">
        <h3>歌手:{{ mvlist.artistName }}</h3>
        <span>发布时间:{{ mvlist.publishTime }}</span>
      </div>
      <div class="right">
        <a :href="mvurl"><img :src="mvlist.cover" alt="" /></a>
      </div>
      <div class="text">mv介绍:{{ mvlist.desc }}</div>
    </div>
    <load-animate v-else></load-animate>
    <comment-list :mvid="id"></comment-list>
  </div>
</template>

<script>
import CommentList from "../components/CommentList.vue";
export default {
  components: { CommentList },
  data() {
    return {
      mvlist: null,
      mvurl: "",
      comments: null,
      showfanhui: false,
    };
  },
  props: {
    id: {
      typeof: String,
      default: "0",
    },
  },
  created() {
    this.getvmlist();
    this.getvmurl();
    this.getcomments();
  },
  methods: {
    async getvmlist() {
      await this.axios.get(`/mv/detail?mvid=${this.id}`).then((res) => {
        this.mvlist = res;
      });
    },
    async getvmurl() {
      await this.axios.get(`/mv/url?id=${this.id}`).then((res) => {
        this.mvurl = res.url;
      });
    },
    async getcomments() {
      await this.axios.get(`/comment/mv?id=${this.id}`).then((res) => {
        this.comments = res.comments;
      });
    },
    back() {
      history.back();
    },
  },
};
</script>

<style lang="scss" scoped>
.mv {
  video {
    width: 100vw;
  }
  .fanhui {
    text-align: center;
    position: absolute;
    font-size: 16px;
    line-height: 45px;
    z-index: 101;
    color: #fff;
    span {
      position: absolute;
      left: 10px;
      top: 5px;
    }
  }
  .content {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 10;
    overflow: hidden;
    .left {
      h3 {
        font-size: 20px;
        color: #666;
        font-weight: bold;
        height: 23px;
        line-height: 23px;
        padding: 10px 0px 10px 10px;
      }
      span {
        display: block;
        padding-bottom: 5px;
        margin-left: 10px;
      }
    }
    .right {
      float: right;
      clear: both;
      font-size: 12px;
      color: #999;
      margin-right: 5px;
      img {
        width: 100px;
        height: 100px;
        border-radius: 50%;
      }
    }
    .text {
      text-indent: 2em;
      color: #999;
      padding: 0px 10px;
    }
  }
}
</style>
